package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class DelOperation implements IOperation{
    @Override
    public void work(BookList bookList){
        System.out.println("删除图书");

        int i = FindName.find(bookList);
        if (i == -1){
            System.out.println("没有这本书");
            return;
        }

        int usedSize = bookList.getUsedSize();
        for (int j = i; j < usedSize - 1; j++) {
            Book book = bookList.getPos(j + 1);
            bookList.setBooks(j,book);
        }

        bookList.setBooks(usedSize-1,null);
        bookList.setUsedSize(usedSize-1);

        System.out.println("删除成功");
    }
}
